cartCfg = $.extend({
	'is_test' : false,
	'referees' : {},//推荐人级别缓存
	'referee_no' : null,//最新推荐人卡号
	
	'is_reserve' : false,//是否有预定产品
	'is_referee' : false,//使用推荐人折扣标志
	'is_coupon' : false,//使用优惠券折扣标志
	'is_activity' : false,//使用活动折扣标志
	
	'is_diamond_global' : false,//全球裸钻
	'diamond_global_shipdate' : 20,//全球裸钻出货时间
	'has_diamond_global' : 0,//购物车中是否有全球裸钻
	
	'member_level' : null,//当前登录用户级别
	'consume_level' : null,//当前消费级别
	
	'discounts' : null,//级别－>折扣数组
	'levels' : null,//级别－>级别名称数组
	
	'actions' : null,//活动操作
	'activitys' : null,//可参加活动信息
	
	'diamond_line' : 0.3//成品享受裸钻折扣，钻重分隔线
},cartCfg);


/**
 * 提交购物车
 */
$('#shopcar_footer_total').click(function(){
	var loginWeb = GetCookie('BriddMember_hadlogin');
	if(loginWeb == 1 && !isBldMmbLogin()){
		memberLoginPop({js:true,url:g_baseUrls.sslBase+'cart/confirm'});
		return;
	}

	if(cartCfg.is_diamond_global&&cartCfg.has_diamond_global){
		commonPromptPop({
			title:'全球钻订购说明',
			width:800,
			top:150,
			promptMsg:getGlobalAgreement({shipdate:true,cert:true,name:true,price:true},true)	
		});
		var date = new Date();
		var time = parseInt(date.getTime()/1000);
		var intervalTime = null;
		var showTime = function(){
			var dateNow = new Date();
			var timeNow = parseInt(dateNow.getTime()/1000);
			timeNow = timeNow - time;
			if(timeNow>=20){
				$('#diamondGlobalTxt').hide();
				$('#diamondGlobalSubmitBtn').show();
				clearInterval(intervalTime);
			}else{
				$('#diamondGlobalTxt').html('同意请继续('+(20-timeNow)+')');
			}
		};
		intervalTime = setInterval(showTime,1000);
		$('#diamondGlobalSubmitBtn').click(function(){
			cartCfg.is_diamond_global = false;
			cartCfg.has_diamond_global = false;
			commonPromptPopClose();
			$('#shopcar_footer_total').click();
		});
		return;
	}

	if( ! cartCfg.is_diamond_global && cartCfg.has_diamond_global)
	{
		commonPromptPop({title:'温馨提醒',promptMsg:'我们建议您将全球钻石单颗单独下单支付结算！'});
		return;
	}
	else
	{
		window.location.href = g_baseUrls.base+'/cart/confirm';
	}
})





/**
 * 购物车清理
 */
var cartDel = function(id, obj){
	if( $.isempty(id) ){
		commonPromptPop({'promptMsg':'您没有选择要删除的商品'});
		return ;
	}
		
	$.blockUI();
	$.ajax({
		type: 'get',
		url: g_baseUrls.base+'/cart/ajaxdel/id/'+id,
		cache : false,
		success: function(resp){try{
			var retcode = $.dealWithRetInDialog(resp,true);
			if(retcode.code == 1){
            	if(typeof retcode.info != 'object'){
            		retcode = eval("(" + retcode.info + ")");
            	}
               
				if(obj){
					obj.parent().parent().parent().hide('nomarl',function(){
						$(this).remove();
					});
				}
				var date = new Date();
				var url = window.location.href;
				url = url.substring(0,url.indexOf("?"));
				window.location.href = url+'?_'+date.getTime();
			}else{
				$(document.body).unblock();
			}
		}catch(e){}},
		error : function(){
			commonPromptPop({'promptMsg':'操作失败，请稍等片刻重新删除商品'});
			$(document.body).unblock();
		}
	});
};




jQ(document).ready(function($){
	/***清空购物车***/
	$(".shopcar_footer_left_2").click(function(){
		$(".shopcar_show_menu_all").show();
	});
	$(".shopcar_show_menu_all_btn_1").click(function(){
	  $(this).parent().hide();
	  cartDel(-1);
	});
	$(".shopcar_show_menu_all_btn_2").click(function(){
		$(this).parent().hide();
	});
	
	
	/***表格高亮***/
	
	/***弹出删除购物车***/
	var indexmun=2;
	$(".shopcar_content_shop_border_close").click(function(){
		console.log('a');
		$(".shopcar_show_menu").hide('nomarl');
		$(this).parents('.vert_subwrap').parents('.shopcar_content_shop_list').find(".shopcar_show_menu").show('nomarl');
		$(this).parents('.vert_subwrap').parents('.shopcar_content_shop_list').css("z-index",indexmun);
		indexmun++;
	});
	/***删除购物车***/
	$(".shopcar_show_menu_btn_1").click(function(){
		cartDel($(this).attr('rel'), $(this));
	});
	/***取消删除购物车***/
	$(".shopcar_show_menu_btn_2").click(function(){
		$(this).parent().hide('nomarl');
	});
	
	
	/***勾选***/
	var select_ablie = true;
	$(".shopcar_agree_select").click(function(){
		if(select_ablie == true){
			$(this).addClass("shopcar_agree_select_click");
			$("#shopcar_footer_total").removeClass("shopcar_footer_total_dis").addClass("shopcar_footer_total").removeAttr("disabled");
			select_ablie = false;
		}else{
			$(this).removeClass("shopcar_agree_select_click");
			$("#shopcar_footer_total").removeClass("shopcar_footer_total").addClass("shopcar_footer_total_dis").attr("disabled","disabled");
			select_ablie = true;
		}
	});
	
	/***阅读协议***/
	$("#read_xiye").click(function(){
		$(".xieyi_zhezhao").show().height(document.body.clientHeight);
		$(".xieyi_border").css("visibility","visible");
	});
	$(".xieyi_close").click(function(){
		$(".xieyi_zhezhao").hide();
		$(".xieyi_border").css("visibility","hidden");
	});
	$(".xieyi_agree").click(function(){
		$(".shopcar_agree_select").addClass("shopcar_agree_select_click");
		$("#shopcar_footer_total").removeClass("shopcar_footer_total_dis").addClass("shopcar_footer_total").removeAttr("disabled");
		$(".xieyi_zhezhao").hide();
		$(".xieyi_border").css("visibility","hidden");
		select_ablie = false;
	});
	
	
	/***自定义滚动条***/
	var num = 0;
	var con_div = 0;
	$(".shopcar_order_shouhuo_div").click(function(){
		num = parseInt($(this).attr("num"));
		con_div = parseInt($(this).attr("con"));
		/*console.log(con_div)*/
		if(con_div == 0){
			$(this).parent().children("#content_"+num).css("visibility","visible");
			con_div++;
			$(this).attr("con",con_div);
		}else{
			$(this).parent().children("#content_"+num).css("visibility","hidden");
			con_div--;
			$(this).attr("con",con_div);
		}
		
	});
	

	
});
(function($){
    $(window).load(function(){
        $("#content_1").mCustomScrollbar({
            scrollButtons:{
                enable:true
            },
            theme:"light-2"
        });
		
		
    });
	
})(jQ);